﻿using System.Text;

namespace 替换空格
{
    internal class Program
    {
        static void Main(string[] args)
        {
            string s = "We are happy.";
            string result = Solution.ReplaceSpace(s);
            Console.WriteLine(result);
            Console.ReadLine();
        }
    }

    public class Solution
    {

        public static string ReplaceSpace(string s)
        {
            StringBuilder sb = new StringBuilder();
            foreach (char c in s)
            {
                if (c == ' ')
                {
                    sb.Append("%20");
                }
                else
                {
                    sb.Append(c);
                }
            }
            return sb.ToString();
        }
    }
}